/-boot ...
BootController.ts
BootLayout.ts
StorageLoader.ts
boot.ts
/-docs
/-docs/CodeMirrorServices
/-docs/api
/-editor
/-files
/-files-old
/-imports
/-layout
/-storage
/-storage/attached
/-storage/attached/api
DetectStorage.ts
LoadStorage.ts
LoadStorageRecipient.ts
UpdateStorage.ts
/-storage/attached/dom
DetectStorage.ts
LoadStorage.ts
UpdateStorage.ts
/-storage/attached/indexedDB
DetectStorage.ts
FileData.ts
LoadStorage.ts
MetadataData.ts
UpdateStorage.ts
functions.ts
/-storage/attached/localStorage
DetectStorage.ts
LoadStorage.ts
UpdateStorage.ts
/-storage/attached/webSQL
/-tests
/-typings
Dom.ts
TypeScriptService.ts
functions.ts
ko.ts
nteapo.html
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
try.html
try.js
xxxxxxxxxx
 
52
53
          this._detectCompleted();
54
        }
55
      });
56
57
      detectWebSQL.detectStorageAsync(this._uniqueKey, (error, load) => {
58
        this._webSqlDetectCompleted = true;
59
60
        if (this._persistence)
61
          return;
62
63
        this._persistence = load;
64
        if (this._indexedDBDetectCompleted)
65
          this._detectCompleted();
66
      });
67
    }
68
69
    private _detectCompleted() {
70
      var loadingFromPersistence = this._persistence && this._persistence.editedUTC > this._domStorage.editedUTC;
71
72
      var sourceLoad = loadingFromPersistence ? this._persistence : this._domStorage;
73
      var targetLoad = loadingFromPersistence ? this._domStorage : this._persistence;
74
75
      console.log('loadingFromPersistence: ' + loadingFromPersistence, sourceLoad, targetLoad);
76
77
      this._callbacks.detectionComplete(
78
        null,
79
        this._persistenceName,
80
        sourceLoad.editedUTC,
81
        loadingFromPersistence);
82
83
      var byFullPath: { [fullPath: string]: { [property: string]: string; }; } = {};
84
      var totalFileCount = 0;
85
      var loadedFileCount = 0;
86
      sourceLoad.load({
87
        files: (fileCount) => {
88
          totalFileCount = fileCount;
89
        },
90
        file: (fullPath: string, values: { [name: string]: string; }) => {
91
          byFullPath[fullPath] = values;
92
          loadedFileCount++;
93
          this._callbacks.loadProgress(totalFileCount || 140, loadedFileCount, fullPath);
94
        },
95
        completed: (sourceUpdater: storage.attached.UpdateStorage) => {
96
97
          if (!loadedFileCount)
98
            throw new Error('Something wrong');
99
          
100
          if (!targetLoad) {
101
            this._callbacks.loadComplete(
102
              null, byFullPath,
103
              sourceUpdater,
104
              null);
105
            return;
106
          }
107
108
          targetLoad.migrate(sourceLoad.editedUTC, byFullPath, (err, targetUpdater) => {
109
            if (err) {
110
              this._callbacks.loadComplete(
111
                err,
112
                byFullPath,
113
                null,
114
                null);
115
            }
116
            else {
117
              this._callbacks.loadComplete(
118
                null,
119
                byFullPath,
120
                loadingFromPersistence ? targetUpdater : sourceUpdater,
121
                loadingFromPersistence ? sourceUpdater : targetUpdater);
122
            }
123
          });
124
        },
125
        failed: (error: Error) => {
97:47